<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/jsp/manage/common/taglibs.jsp" %>
<div class="body" style="position: relative">
    <div style="position: absolute;left: 20px;top:10px ; width: 70px; text-align: center;color: #47a6f5;cursor:pointer;border: 1px solid  #47a6f5;line-height: 28px"
         onclick="manage_sys_opens('中心机房','/manage/demo/powerPage/tosecondaryPages.html')">返回</div>
<div class="container"><div class="EMStop1"></div></div>
<div class="container1">
    <div class="EMSUspContent"><p class="EMStitle" style="position: absolute;top:40px ;position: relative">门磁感应实时监控</p>
        <div class="content">
            <div class="left">
                <div class="upsSd" style="background-image: url('/manage/assert/image/kongkai.png');">
                    <div class="loading" id="box">
                       
                    </div>
                </div>
                <p>连接状态 :<span class="linkSuccess"></span></p>
            </div>
            <div style="height: 300px;">
                <div class="right" style="height: 70px;margin-top: 115px">
                <table id="cabinet_table" border="2">
                    <tr>
                        <th class="blueBg">设备状态</th>
                        <td ><span name="state"></span></td>
                        <th class="blueBg">传感器状态</th>
                        <td><span name="sensorstate"></span></td>
                    </tr>
                    <tr>
                        <th clwindspeedass="blueBg">电池状态</th>
                        <td><span name="batterystate"></span></td>
                        <th class="blueBg">防拆状态</th>
                        <td><span name="tamperstate"></span></td>
                    </tr>
                    <tr>
                        <th class="blueBg">按键状态</th>
                        <td><span name="keystate"></span></td>
                        <th class="blueBg">crc16高字节</th>
                        <td><span name="crchighbytes"></span></td>
                    </tr>
                    <tr>
                        <th class="blueBg">crc16低字节</th>
                        <td><span name="crclowhbytes"></span></td>
                        <th class="blueBg">帧尾</th>
                        <td><span name="frametail"></span></td>
                    </tr>
                </table>
                </div>
             </div>
        </div>
    </div>
</div>

</div>
<script>
    $(function () {
        var count = 0;
        var t = setInterval(function () {
            var $redDiv = $("#box").find(".greenBg");
            if(count === 15){
                count=-1;
                $("#box").find('.greenBg').removeClass('greenBg').addClass('white');
                $redDiv=$("#box").find(".first");
                $("#box").find(".last").removeClass("greenBg").addClass("white");
            }
            $redDiv.next().removeClass("white").addClass("greenBg");
            count++;
        }, 1000);


        $.post("/manage/demo/equipment/fetchLastData.html?eids="+ $.websocket.kgl,function (entity) {
            // var entity = JSON.parse(socketMsg.entity)
            if (entity.equipmentid == $.websocket.menci) {//门磁??????
                if (entity.state == '00') {

                } else {
                    $("#accessControl_table span[name='mcbj']").removeClass("linkSuccess");
                    $("#accessControl_table span[name='mcbj']").addClass("linkSuccessred");
                }
                if (entity.state == '10') {
                    $("#accessControl_table span[name='mcbz']").text('红外故障');
                }
                if (entity.state == '01') {
                    $("#accessControl_table span[name='mcbz']").text('红外告警');
                }
                //门磁感器数据
                if (entity.state == '00') {
                    $("#cabinet_table span[name='state']").text('正常');
                } else {
                    $("#cabinet_table span[name='state']").text('报警');
                }
                if (entity.sensorstate == '00') {
                    $("#cabinet_table span[name='sensorstate']").text('正常');
                } else if (entity.sensorstate == '01') {
                    $("#cabinet_table span[name='sensorstate']").text('故障');
                }
                if (entity.batterystate == '00') {
                    $("#cabinet_table span[name='batterystate']").text('正常');
                } else if (entity.batterystate == '01') {
                    $("#cabinet_table span[name='batterystate']").text('低电');
                }
                if (entity.tamperstate == '0') {
                    $("#cabinet_table span[name='tamperstate']").text('正常');
                } else if (entity.tamperstate == '1') {
                    $("#cabinet_table span[name='tamperstate']").text('被拆');
                }
                if (entity.keystate == '000') {
                    $("#cabinet_table span[name='keystate']").text('正常');
                } else if (entity.keystate == '001') {
                    $("#cabinet_table span[name='keystate']").text('测试');
                }
                $("#cabinet_table span[name='crchighbytes']").text(entity.crchighbytes);
                $("#cabinet_table span[name='crclowhbytes']").text(entity.crclowhbytes);
                $("#cabinet_table span[name='frametail']").text(entity.frametail);
            }
        })

    });
</script>